Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add feature: no-metadata-doc which removes doc from metadata and full-metadata which build metadata with all doc #10493

Merged
merged 5 commits into from
Jan 17, 2022

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Dec 15, 2021

Fix #9235

Currently the metadata contains some doc for some types.

This PR add 2 new features:

  • no-metadata-docs which most docs from types. and docs from storage and constant. Note: this doesn't remove docs from other types which define scale_info(capture_doc = "always") if some other types make use of such attribute, their crate should provide a feature to remove their doc as well. (in substrate I'm not aware of other types always capturing docs).
  • full-metadata-docs which will add the doc for most types. It simply activate the feature scale_info/docs which enables docs on types by default. So all types that end up in the metadata will have their documentation.

Note: this PR is not a breaking change, current behavior is still the default behavior.

TODO:

  • test for event/call/error.

@github-actions github-actions bot added the A3-in_progress Pull request is in progress. No review needed at this stage. label Dec 15, 2021
@gui1117 gui1117 marked this pull request as ready for review December 16, 2021 06:51
@gui1117 gui1117 requested a review from a team as a code owner December 16, 2021 06:51
@github-actions github-actions bot added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Dec 16, 2021
@gui1117 gui1117 added B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Dec 16, 2021
@gui1117 gui1117 changed the title Add feature: no-metadata-doc which removes doc from metadata Add feature: no-metadata-doc which removes doc from metadata and full-metadata which build metadata with all doc Dec 16, 2021
Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me

@@ -137,6 +137,8 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
let count = COUNTER.with(|counter| counter.borrow_mut().inc());
let macro_ident = syn::Ident::new(&format!("__is_call_part_defined_{}", count), span);

let capture_docs = if cfg!(feature = "no-metadata-docs") { "never" } else { "always" };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would have liked a test that would fail if the rust team decided to change these two pairs to Never and Always, but I guess that's extremely unlikely at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is scale-info crate, I think if they do such change, they will do compile-time error for invalid input

grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
…ull-metadata` which build metadata with all doc (paritytech#10493)

* add features to remove or add doc

* fmt

* add test for event/error/call

* fmt
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…ull-metadata` which build metadata with all doc (paritytech#10493)

* add features to remove or add doc

* fmt

* add test for event/error/call

* fmt
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature flags to disable docs in metadata
6 participants